package com.openbravo.pos.panels.model;

import cn.ekuma.data.ui.swing.AbstractDTOTableModel;

import com.openbravo.bean.Product;
import com.openbravo.format.Formats;
import com.openbravo.pos.base.AppConfig;
import com.openbravo.pos.base.AppLocal;


public class ProductViewTableModel extends AbstractDTOTableModel<Product> {

	 boolean showBuyPrice;
	
    public ProductViewTableModel() {
		super();
		showBuyPrice="true".equals(AppConfig.getAppProperty(AppConfig.SHOW_BUY_PRICE));
	}


	@Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        Product inculdProduct = objs.get(rowIndex);
         switch(columnIndex){
             case 0:
                  return inculdProduct.getReference();
             case 1:
                 return inculdProduct.getCode();
             case 2:
                 return inculdProduct.getName();
             case 3:
                 return inculdProduct.getSpecification();
             case 4:
                 return Formats.CURRENCY.formatValue(inculdProduct.getPriceSell());
             case 5:    
             	return Formats.CURRENCY.formatValue(inculdProduct.getM_dCustomerPrice());
             case 6:
            	 return inculdProduct.getM_sManufacturer();
             case 7:
            	 return inculdProduct.getM_origin();
             case 8:
            	 return inculdProduct.getM_iDurability();
             case 9:
            	 return inculdProduct.isCom()?"Y":" ";
             case 10:
            	 return inculdProduct.getM_quantity();
             case 11:
            	 return showBuyPrice==true?inculdProduct.getPriceBuy():"***";
             }
         return null;
    }


    public String[] getColumnNames() {
        return new String[] {
        		AppLocal.getIntString("label.prodref"),
        		AppLocal.getIntString("label.prodbarcode"),
                AppLocal.getIntString("label.prodname"),
                AppLocal.getIntString("label.prodSpecification"),
                AppLocal.getIntString("label.prodpricesell"),
                AppLocal.getIntString("label.baseCustomerPrice"),
                AppLocal.getIntString("label.prodcut.m_sManufacturer"),
                AppLocal.getIntString("label.product.origin"),
                AppLocal.getIntString("label.product.m_iDurability"),
                AppLocal.getIntString("label.prodaux"),
                AppLocal.getIntString("label.product.quantity"),
                AppLocal.getIntString("label.prodpricebuy")
                };
    }
}
